<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>相对定位</title>
  <style>
    .box1,
    .box2,
    .box3 {
      width: 100px;
      height: 100px;
    }

    .box1 {
      background-color: blue;
    }

    .box2 {
      position: relative;
      top: 50px;
      left: 50px;
      right: 50px;
      background-color: pink;
    }

    .box3 {
      background-color: skyblue;
    }
  </style>
</head>

<body>
  <div class="box1"></div>
  <div class="box2"></div>
  <div class="box3"></div>
</body>

</html>